<?php
/*
Description: This file is used to change login paassword.
*/
#########IncludeFiles####################################################################################
include_once '../inc/config.php';
include_once("../inc/bootstrape.php");
require_once _SITE_PATH_.'classes/CommonUtility/CommonUtility.php';

//	END CHANGE PASSWORD CODE	//
$errMsg = $_GET['err'];
$action = trim($_REQUEST['action']);
$id = trim($_REQUEST['id']); 
if(empty($id)){
    header("Location: "._SITE_ADMIN_URL_."access-module/access_group_mng.php");
    exit;
}

if(isset($_POST['submit'])){
    $parms['group_name'] = $_POST['group_name'];
    $moduleStr = '';
    foreach( $_POST['module_id'] as $val ){
        $moduleStr[] = $val . '::'. @implode('-',$_POST['op_'.$val]);;        
    }
    $parms['module_id'] = @implode(',',$moduleStr);
    //$parms['module_id'] = @implode(',',$_POST['module_id']);        
    $condition = array(); 
    $condition['id'] = $id;
    if( CommonUtility::updateData($parms, 'access_group', $condition)) {        
        header("Location: access_group_mng.php?msg=1063");
        exit;
    }
    $errMsg = 1064;    
}
if( $errMsg ){
    $result = $_POST;
    
}else{
    $result = CommonUtility::getDataById($id, 'access_group');   
    $result['module_id'] =  explode(',', $result['module_id']);    
}

$_tplName = 'access-module/access_group_edit.tpl';
$_title = 'Edit Access Group';
require_once _ADMIN_TPL_MAIN_;
?>